/**
 * Created by Administrator on 2017/3/18.
 */
"use strict";


$(document).ready(function () {

    //图片延迟加载
    var loading = '/public/static/images/common/loading.gif';
    $("img.lazy").lazyload({
        placeholder: loading, //用图片提前占位
        effect: "fadeIn",
        threshold: 200,
        failurelimit : 4,
    });

    //瀑布流
    var container = $('.wall');
    container.imagesLoaded(function () {
        container.fadeIn();
        container.masonry({
            itemSelector: '.wall > .item',
            isAnimated: true,
        });
    });

    //返回顶部
    $(window).scroll(function () {
        if ($(this).scrollTop() > 100) {
            $('#back-to-top').fadeIn();
        } else {
            $('#back-to-top').fadeOut();
        }
    });
    $('#back-to-top').on('click', function (e) {
        e.preventDefault();
        $('html, body').animate({scrollTop: 0}, 1000);
        return false;
    });

    //百度推送
    (function () {
        var bp = document.createElement('script');
        var curProtocol = window.location.protocol.split(':')[0];
        if (curProtocol === 'https') {
            bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
        }
        else {
            bp.src = 'http://push.zhanzhang.baidu.com/push.js';
        }
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(bp, s);
    })();

});